package io.gitee.sfch.chunmi.conf.listener;

import com.mybatisflex.annotation.AbstractInsertListener;
import io.gitee.sfch.chunmi.entity.ImmutableEntity;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * {@link ImmutableEntity} 不可变实体添加新增信息
 */
@Component
public class ImmutableEntityInsertListener extends AbstractInsertListener<ImmutableEntity> {

    @Override
    public void doInsert(ImmutableEntity entity) {
        entity.setCreateTime(LocalDateTime.now());
        entity.setCreatorId(-1L);
    }
}
